import java.util.Random;
import java.util.List;
import java.util.ArrayList;

public class RandomStringGenerator {
	private static final Random RANDOM = new Random();
	private List<Character> characters;

	public RandomStringGenerator() {

		this.characters = new ArrayList<Character>();

		// numbers
		for (int i = 0; i < 10; i++)
			this.characters.add((char) ('0' + i));

		// lowercase letters
		for (int i = 0; i < 26; i++)
			this.characters.add((char) ('a' + i));

		// uppercase letters
		for (int i = 0; i < 26; i++)
			this.characters.add((char) ('A' + i));

	}

	public String next(long size) {
		StringBuilder builder = new StringBuilder();
		for (long i = 0; i < size; i++) {
			int randomIndex = RANDOM.nextInt(characters.size());
			char randomChar = characters.get(randomIndex);
			builder.append(randomChar);
		}

		return builder.toString();
	}
}
